/*package com.trkj.service.lzs;


import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.trkj.dao.lzs.SalaryProjectDao;
import com.trkj.dao.lzs.SalarySableDao;
import com.trkj.pojo.ProjectTemplate;


@Service
@Transactional(rollbackFor = Exception.class)
public class SalaryTemplateService {
	@Autowired
	private SalarySableDao salaryTemplateDao;
	@Autowired
	private SalaryProjectDao salaryProjectDao;
	
	*//**
	 * 分页查询
	 * @param page
	 * @param rows
	 * @return
	 *//*
	public List<ProjectTemplate> templateQueryPage(int page,int rows){
		return salaryTemplateDao.queryPage(new PageRequest(page-1,rows));
	}
	public List<TemplateVo> templateQueryPage(String text,int page,int rows){
		List<ProjectTemplate> list= salaryTemplateDao.queryPage("%"+text+"%",new PageRequest(page-1,rows));
		List<TemplateVo> list1 = new ArrayList<>();
		for(ProjectTemplate s:list){
			TemplateVo vo = new TemplateVo();
			vo.setTemplateId(s.getTemplateId());
			vo.setTemplateName(s.getTemplateName());
			vo.setTemplateCreatordate(s.getTemplateCreatordate());
			vo.setTemplatePerson(s.getTemplatePerson());
			vo.setTemplateRemarks(s.getTemplateRemarks());
			if(!s.getSalaryProjects().isEmpty()){				
				vo.setProjectNum(s.getSalaryProjects().size());
			}
			list1.add(vo);
		}
		return list1;
	}
	
	*//**
	 * 获取总记录数
	 * @return
	 *//*
	public long templateCountPage(){
		return salaryTemplateDao.count();
	}
	public long templateCountPage(String text){
		return salaryTemplateDao.counts("%"+text+"%");
	}
	
	*//**
	 * 新增模板
	 * @param projectTemplate
	 * @param templatePerson
	 * @throws ServiceException 
	 *//*
	public void newTemplate(ProjectTemplate projectTemplate,String templatePerson) throws ServiceException{
		try {
			projectTemplate.setTemplateCreatordate(new Timestamp(new Date().getTime()));
			projectTemplate.setTemplatePerson(templatePerson);
			salaryTemplateDao.save(projectTemplate);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	*//**
	 * 删除模板
	 * @param templateId
	 * @throws ServiceException 
	 *//*
	public void deleteTemplate(Long templateId) throws ServiceException{
		try {
			salaryProjectDao.delete(templateId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	*//**
	 * 修改模板
	 * @param templateId
	 * @param templateName
	 * @throws ServiceException 
	 *//*
	public void updateTemplate(Long templateId,String templateName) throws ServiceException{
		try {
			ProjectTemplate projectTemplate = salaryTemplateDao.findOne(templateId);
			projectTemplate.setTemplateName(templateName);
			salaryTemplateDao.save(projectTemplate);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	*//**
	 * 查询模板信息
	 * @param templateId
	 * @return
	 * @throws ServiceException
	 *//*
	public ProjectTemplate findOneTemplate(Long templateId) throws ServiceException {
		try {
			return salaryTemplateDao.findOne(templateId);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
//多表
	*//**
	 * 模板关联薪资项目
	 * @param projectId
	 * @param templateId
	 * @throws ServiceException 
	 *//*
	public void RelevanceProject(Long[] projectId,Long templateId) throws ServiceException{
		try {
			ProjectTemplate projectTemplate = salaryTemplateDao.findOne(templateId);
			List<SalaryProject> list = new ArrayList<>();
			for(int i=0;i<projectId.length;i++){
				SalaryProject salaryProject = salaryProjectDao.findOne(projectId[i]);
				list.add(salaryProject);
				if(!salaryProject.getProjectTemplates().isEmpty()){
					salaryProject.getProjectTemplates().add(projectTemplate);
				}else{
					List<ProjectTemplate> lis=new ArrayList<>();
					lis.add(projectTemplate);
					salaryProject.setProjectTemplates(lis);
				}
			}
			projectTemplate.setSalaryProjects(list);
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	*//**
	 * 模板新增项目
	 * @param templateId
	 * @param salaryProject
	 * @param projectPerson
	 * @throws ServiceException 
	 *//*
	public void TemplateAddProject(Long templateId,SalaryProject salaryProject,String projectPerson) throws ServiceException{
		try {
			ProjectTemplate projectTemplate = salaryTemplateDao.findOne(templateId);	
			//新增项目
			salaryProject.setProjectPerson(projectPerson);
			salaryProject.setProjectCreatordate(new Timestamp(new Date().getTime()));
			salaryProject.setProjectUpdatedate(new Timestamp(new Date().getTime()));
			//项目添加模板
			List<ProjectTemplate> list=new ArrayList<>();
			list.add(projectTemplate);
			salaryProject.setProjectTemplates(list);
			salaryProjectDao.save(salaryProject);
			//模板添加项目
			if(!projectTemplate.getSalaryProjects().isEmpty()){
				projectTemplate.getSalaryProjects().add(salaryProject);
			}else{
				List<SalaryProject> list1=new ArrayList<>();
				list1.add(salaryProject);
				projectTemplate.setSalaryProjects(list1);
			}
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
	
	*//**
	 * 查询模板关联的薪资项目
	 * @param projectId
	 * @param templateId
	 * @return
	 * @throws ServiceException 
	 *//*
	public List<SalaryProject> queryRelevanceProject(Long templateId) throws ServiceException{
		try {
			ProjectTemplate projectTemplate = salaryTemplateDao.findOne(templateId);
			List<SalaryProject> list = null;
			if(!projectTemplate.getSalaryProjects().isEmpty()){
				 list = projectTemplate.getSalaryProjects();	
			}
			for (SalaryProject salaryProject : list) {
			}
			return list;
		} catch (Exception e) {
			e.printStackTrace();
			throw new ServiceException(e);
		}
	}
}
*/